\hypertarget{class_udp_server}{\section{Udp\+Server类 参考}
\label{class_udp_server}\index{Udp\+Server@{Udp\+Server}}
}


Udp\+Server类  




{\ttfamily \#include $<$Socket.\+h$>$}

类 Udp\+Server 继承关系图\+:\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[height=3.000000cm]{class_udp_server}
\end{center}
\end{figure}
\subsection*{Public 成员函数}
\begin{DoxyCompactItemize}
\item 
sint32 \hyperlink{class_udp_server_adf6dbeb29365bf50fef8066bb28b188a}{init\+Server} (uint16 server\+Port, std\+::string server\+I\+P=\char`\"{}127.\+0.\+0.\+1\char`\"{}, uint32 max\+Pendings=1)
\begin{DoxyCompactList}\small\item\em 初始化服务器 \end{DoxyCompactList}\item 
sint32 \hyperlink{class_udp_server_a98091976a63665f6c379081f95273a62}{start\+Server} ()
\begin{DoxyCompactList}\small\item\em 启动服务器 \end{DoxyCompactList}\item 
sint32 \hyperlink{class_udp_server_ad18f2533425a859d120516cd839b2c1f}{stop\+Server} ()
\begin{DoxyCompactList}\small\item\em 停止服务器 \end{DoxyCompactList}\item 
\hyperlink{class_socket}{Socket} $\ast$$\ast$ \hyperlink{class_udp_server_afacf9b5e5ed67e53ac4d6af1cadebaf7}{get\+Server\+Socket} ()
\begin{DoxyCompactList}\small\item\em 获取服务端\+Socket \end{DoxyCompactList}\item 
\hyperlink{class_socket}{Socket} $\ast$$\ast$ \hyperlink{class_udp_server_aef89fbbe4ab487ff45a946ab813c18fa}{get\+Client\+Socket} ()
\begin{DoxyCompactList}\small\item\em 获取客户端\+Socket \end{DoxyCompactList}\item 
virtual sint32 \hyperlink{class_udp_server_ad6a00822c7b318204d96057e5913309e}{recv\+Data} (char $\ast$buf, sint32 len)
\begin{DoxyCompactList}\small\item\em 服务器接收数据方法 \end{DoxyCompactList}\item 
virtual sint32 \hyperlink{class_udp_server_ab4f6ac2151bbbfd421cbe11df2f4d63e}{send\+Data} (const char $\ast$buf, sint32 len)
\begin{DoxyCompactList}\small\item\em 服务器发送数据方法 \end{DoxyCompactList}\item 
\hypertarget{class_udp_server_a36da1fdf692cbfa1bdf36e8f9f25bdae}{virtual void {\bfseries service\+Loop} ()=0}\label{class_udp_server_a36da1fdf692cbfa1bdf36e8f9f25bdae}

\end{DoxyCompactItemize}


\subsection{详细描述}
Udp\+Server类 

\subsection{成员函数说明}
\hypertarget{class_udp_server_aef89fbbe4ab487ff45a946ab813c18fa}{\index{Udp\+Server@{Udp\+Server}!get\+Client\+Socket@{get\+Client\+Socket}}
\index{get\+Client\+Socket@{get\+Client\+Socket}!Udp\+Server@{Udp\+Server}}
\subsubsection[{get\+Client\+Socket}]{\setlength{\rightskip}{0pt plus 5cm}{\bf Socket} $\ast$$\ast$ Udp\+Server\+::get\+Client\+Socket (
\begin{DoxyParamCaption}
{}
\end{DoxyParamCaption}
)}}\label{class_udp_server_aef89fbbe4ab487ff45a946ab813c18fa}


获取客户端\+Socket 


\begin{DoxyParams}{参数}
{\em void} & \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{返回}
返回客户端\+Socket 
\end{DoxyReturn}
\begin{DoxyNote}{注解}
none 
\end{DoxyNote}
\hypertarget{class_udp_server_afacf9b5e5ed67e53ac4d6af1cadebaf7}{\index{Udp\+Server@{Udp\+Server}!get\+Server\+Socket@{get\+Server\+Socket}}
\index{get\+Server\+Socket@{get\+Server\+Socket}!Udp\+Server@{Udp\+Server}}
\subsubsection[{get\+Server\+Socket}]{\setlength{\rightskip}{0pt plus 5cm}{\bf Socket} $\ast$$\ast$ Udp\+Server\+::get\+Server\+Socket (
\begin{DoxyParamCaption}
{}
\end{DoxyParamCaption}
)}}\label{class_udp_server_afacf9b5e5ed67e53ac4d6af1cadebaf7}


获取服务端\+Socket 


\begin{DoxyParams}{参数}
{\em void} & \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{返回}
返回服务端\+Socket 
\end{DoxyReturn}
\begin{DoxyNote}{注解}
none 
\end{DoxyNote}
\hypertarget{class_udp_server_adf6dbeb29365bf50fef8066bb28b188a}{\index{Udp\+Server@{Udp\+Server}!init\+Server@{init\+Server}}
\index{init\+Server@{init\+Server}!Udp\+Server@{Udp\+Server}}
\subsubsection[{init\+Server}]{\setlength{\rightskip}{0pt plus 5cm}sint32 Udp\+Server\+::init\+Server (
\begin{DoxyParamCaption}
\item[{uint16}]{server\+Port, }
\item[{std\+::string}]{server\+I\+P = {\ttfamily \char`\"{}127.0.0.1\char`\"{}}, }
\item[{uint32}]{max\+Pendings = {\ttfamily 1}}
\end{DoxyParamCaption}
)}}\label{class_udp_server_adf6dbeb29365bf50fef8066bb28b188a}


初始化服务器 


\begin{DoxyParams}{参数}
{\em server\+Port} & 服务器端口 \\
\hline
{\em max\+Con\+Allows} & 服务器最多支持挂起连接数(仅\+T\+C\+P时有效) \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{返回}
成功返回\+S\+T\+A\+T\+U\+S\+\_\+\+O\+K,失败返回\+S\+T\+A\+T\+U\+S\+\_\+\+E\+R\+R\+O\+R 
\end{DoxyReturn}
\begin{DoxyNote}{注解}
none 
\end{DoxyNote}
\hypertarget{class_udp_server_ad6a00822c7b318204d96057e5913309e}{\index{Udp\+Server@{Udp\+Server}!recv\+Data@{recv\+Data}}
\index{recv\+Data@{recv\+Data}!Udp\+Server@{Udp\+Server}}
\subsubsection[{recv\+Data}]{\setlength{\rightskip}{0pt plus 5cm}sint32 Udp\+Server\+::recv\+Data (
\begin{DoxyParamCaption}
\item[{char $\ast$}]{buf, }
\item[{sint32}]{len}
\end{DoxyParamCaption}
)\hspace{0.3cm}{\ttfamily [virtual]}}}\label{class_udp_server_ad6a00822c7b318204d96057e5913309e}


服务器接收数据方法 


\begin{DoxyParams}{参数}
{\em buf} & 接收缓存 \\
\hline
{\em len} & 缓存的大小 \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{返回}
返回值ret大于0表示接收到ret个数据,等于0表示断开连接,小于0表示接收失败 
\end{DoxyReturn}
\begin{DoxyNote}{注解}
默认为\+Socket的接收方法,用户可覆盖以定制自己的接收方法 
\end{DoxyNote}


被 \hyperlink{class_tcp_server_a734911e336ac9231c6acbbf2494e6ba8}{Tcp\+Server} 重载.

\hypertarget{class_udp_server_ab4f6ac2151bbbfd421cbe11df2f4d63e}{\index{Udp\+Server@{Udp\+Server}!send\+Data@{send\+Data}}
\index{send\+Data@{send\+Data}!Udp\+Server@{Udp\+Server}}
\subsubsection[{send\+Data}]{\setlength{\rightskip}{0pt plus 5cm}sint32 Udp\+Server\+::send\+Data (
\begin{DoxyParamCaption}
\item[{const char $\ast$}]{buf, }
\item[{sint32}]{len}
\end{DoxyParamCaption}
)\hspace{0.3cm}{\ttfamily [virtual]}}}\label{class_udp_server_ab4f6ac2151bbbfd421cbe11df2f4d63e}


服务器发送数据方法 


\begin{DoxyParams}{参数}
{\em buf} & 发送数据 \\
\hline
{\em len} & 数据长度 \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{返回}
成功返回发送的数据长度,失败返回\+S\+T\+A\+T\+U\+S\+\_\+\+E\+R\+R\+O\+R 
\end{DoxyReturn}
\begin{DoxyNote}{注解}
默认为\+Socket的发送方法,用户可覆盖以定制自己的发送方法 
\end{DoxyNote}


被 \hyperlink{class_tcp_server_a3b42dcd08441b83b3474a1647df9211e}{Tcp\+Server} 重载.

\hypertarget{class_udp_server_a98091976a63665f6c379081f95273a62}{\index{Udp\+Server@{Udp\+Server}!start\+Server@{start\+Server}}
\index{start\+Server@{start\+Server}!Udp\+Server@{Udp\+Server}}
\subsubsection[{start\+Server}]{\setlength{\rightskip}{0pt plus 5cm}sint32 Udp\+Server\+::start\+Server (
\begin{DoxyParamCaption}
{}
\end{DoxyParamCaption}
)}}\label{class_udp_server_a98091976a63665f6c379081f95273a62}


启动服务器 


\begin{DoxyParams}{参数}
{\em void} & \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{返回}
成功返回\+S\+T\+A\+T\+U\+S\+\_\+\+O\+K,失败返回\+S\+T\+A\+T\+U\+S\+\_\+\+E\+R\+R\+O\+R 
\end{DoxyReturn}
\begin{DoxyNote}{注解}
none 
\end{DoxyNote}
\hypertarget{class_udp_server_ad18f2533425a859d120516cd839b2c1f}{\index{Udp\+Server@{Udp\+Server}!stop\+Server@{stop\+Server}}
\index{stop\+Server@{stop\+Server}!Udp\+Server@{Udp\+Server}}
\subsubsection[{stop\+Server}]{\setlength{\rightskip}{0pt plus 5cm}sint32 Udp\+Server\+::stop\+Server (
\begin{DoxyParamCaption}
{}
\end{DoxyParamCaption}
)}}\label{class_udp_server_ad18f2533425a859d120516cd839b2c1f}


停止服务器 


\begin{DoxyParams}{参数}
{\em void} & \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{返回}
成功返回\+S\+T\+A\+T\+U\+S\+\_\+\+O\+K,失败返回\+S\+T\+A\+T\+U\+S\+\_\+\+E\+R\+R\+O\+R 
\end{DoxyReturn}
\begin{DoxyNote}{注解}
none 
\end{DoxyNote}


该类的文档由以下文件生成\+:\begin{DoxyCompactItemize}
\item 
libemb/inc/\hyperlink{_socket_8h}{Socket.\+h}\item 
libemb/src/Socket.\+cpp\end{DoxyCompactItemize}
